package com.zjn.zjngraduationdesign.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.zjn.zjngraduationdesign.entity.User;
import com.zjn.zjngraduationdesign.service.AdminService;

@Controller
@RequestMapping("/admin")
public class AdminController {
	
	@Autowired
	AdminService adminService;
	
	@RequestMapping(value="index")
	public String index() { 	
		
		return "admin/index";
	}

	@RequestMapping(value="login")
	public String login(String aname, String apwd, ModelMap model){
				
		boolean flag = adminService.checkLogin(aname, apwd);
		if(flag) {
			return "admin/admin-index";
		}
		return "index";
		
	}
	
	@RequestMapping(value="find")
	public ModelAndView findAll() {
		ModelAndView mav = new ModelAndView("admin/userList");
		List<User> list = adminService.findAllUser();
		mav.addObject("list", list);
		return mav;
		
	}


}
